﻿using System;

namespace Microsoft.SPOT.Hardware
{
    public abstract class SPI : IDisposable
    {
        public SPI(SPI.Configuration config)
        {

        }

        public SPI.Configuration Config { get; set; }

        public abstract void Dispose();
        public abstract void Write(byte[] writeBuffer);
        public abstract void Write(ushort[] writeBuffer);
        public abstract void WriteRead(byte[] writeBuffer, byte[] readBuffer);
        public abstract void WriteRead(ushort[] writeBuffer, ushort[] readBuffer);
        public abstract void WriteRead(byte[] writeBuffer, byte[] readBuffer, int startReadOffset);
        public abstract void WriteRead(ushort[] writeBuffer, ushort[] readBuffer, int startReadOffset);
        public abstract void WriteRead(byte[] writeBuffer, int writeOffset, int writeCount, byte[] readBuffer, int readOffset, int readCount, int startReadOffset);
        public abstract void WriteRead(ushort[] writeBuffer, int writeOffset, int writeCount, ushort[] readBuffer, int readOffset, int readCount, int startReadOffset);

        public enum SPI_module
        {
            SPI1 = 0,
            SPI2 = 1,
            SPI3 = 2,
            SPI4 = 3,
        }

        public class Configuration
        {
            public readonly Cpu.Pin BusyPin;
            public readonly bool BusyPin_ActiveState;
            public readonly bool ChipSelect_ActiveState;
            public readonly uint ChipSelect_HoldTime;
            public readonly Cpu.Pin ChipSelect_Port;
            public readonly uint ChipSelect_SetupTime;
            public readonly bool Clock_Edge;
            public readonly bool Clock_IdleState;
            public readonly uint Clock_RateKHz;
            public readonly SPI.SPI_module SPI_mod;

            public Configuration(Cpu.Pin ChipSelect_Port, bool ChipSelect_ActiveState, uint ChipSelect_SetupTime, uint ChipSelect_HoldTime, bool Clock_IdleState, bool Clock_Edge, uint Clock_RateKHz, SPI.SPI_module SPI_mod)
            {

            }

            public Configuration(Cpu.Pin ChipSelect_Port, bool ChipSelect_ActiveState, uint ChipSelect_SetupTime, uint ChipSelect_HoldTime, bool Clock_IdleState, bool Clock_Edge, uint Clock_RateKHz, SPI.SPI_module SPI_mod, Cpu.Pin BusyPin, bool BusyPin_ActiveState)
            {

            }
        }
    }
}
